var MutationViewerApp = MutationViewerApp || {};
MutationViewerApp.view = MutationViewerApp.view || {};

MutationViewerApp.view.SummaryView = Backbone.View.extend({
    initialize: function(options) {
        this.dispatcher = options.dispatcher;

        this.collection.on('reset', function(d) {
            this.render();
        }, this);

        this.render();
    },

    render: function() {
        if (this.collection.toJSON().length == 0)
        {
            $('#protein_info .info_field', this.$el).html('NA');
            return this;
        }

        var protein_data = this.collection.toJSON()[0].protein;
        $('#protein_info .uniprot_id', this.$el).html(protein_data.uniprot_id);
        $('#protein_info .entry_name', this.$el).html(protein_data.entry_name);
        $('#protein_info .protein_name', this.$el).html(protein_data.protein_name);
        $('#protein_info .protein_length', this.$el).html(protein_data.sequence_length);

        return this;
    }
});
